Skip to content

Conversation

@tenderlove
Copy link
Member

parse.y treats CRLF as a LF and basically "normalizes" them before parsing. That means a string like %\nfoo\r\n is actually treated as %\nfoo\n for the purposes of parsing. This happens on both the opening side of the percent string as well as on the closing side. So for example %\r\nfoo\n must be treated as %\nfoo\n.

To handle this in Prism, when we start a % string, we check if it starts with \r\n, and then consider the terminator to actually be \n. Then we check if there are \r\n as we lex the string and treat those as \n, but only in the case the start was a \n.

Fixes: #3230

[Bug #20938]

@tenderlove tenderlove force-pushed the eileencodes-partially-fix-3230 branch 2 times, most recently from 1bee057 to eeea2cb Compare December 11, 2024 21:32
parse.y treats CRLF as a LF and basically "normalizes" them before
parsing.  That means a string like `%\nfoo\r\n` is actually treated as
`%\nfoo\n` for the purposes of parsing.  This happens on both the
opening side of the percent string as well as on the closing side.  So
for example `%\r\nfoo\n` must be treated as `%\nfoo\n`.

To handle this in Prism, when we start a % string, we check if it starts
with `\r\n`, and then consider the terminator to actually be `\n`.  Then
we check if there are `\r\n` as we lex the string and treat those as
`\n`, but only in the case the start was a `\n`.

Fixes: #3230

[Bug #20938]

Co-authored-by: John Hawthorn <[email protected]>
Co-authored-by: eileencodes <[email protected]>
Co-authored-by: Kevin Newton <[email protected]>
@tenderlove tenderlove force-pushed the eileencodes-partially-fix-3230 branch from eeea2cb to e573cea Compare December 11, 2024 22:10
@tenderlove tenderlove merged commit 88c71b8 into main Dec 11, 2024
56 checks passed
@tenderlove tenderlove deleted the eileencodes-partially-fix-3230 branch December 11, 2024 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parsing %\r...\r with CRLF different from parse.y

4 participants